package com.example.mylibrarybase.yumengmeng12.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.mylibrarybase.R;
import com.example.mylibrarybase.yumengmeng12.base.baseRecyclerview;
import com.example.mylibrarybase.yumengmeng12.bean.item_json;

/**
 * Created by 35876 于萌萌
 * 创建日期: 13:47 . 2016年10月21日
 * 描述:
 * <p>
 * <p>
 * 备注:
 */

public  class itemRecyclerview extends baseRecyclerview<item_json> {
    private static final int TYPE_0 = 0;
    private static final int TYPE_1 = 1;
    private static final int TYPE_2 = 2;
    private static final int TYPE_3 = 3;
    private static final int TYPE_4 = 4;
    private static final int TYPE_5 = 5;
    private static final int TYPE_6 = 6;
    private static final int TYPE_7 = 7;


    public itemRecyclerview(Context context, int card, item_json json) {
        super(context, card, json);
    }


    @Override
    protected itemView initonCreateViewHolder(ViewGroup parent, int viewType) {
        myItemView itemView =null;
        switch (viewType){
            case TYPE_0:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_0_12,parent,false));
                itemView.initView00();
                break;
            case TYPE_1:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_1_12,parent,false));
                itemView.initView01();
                break;
            case TYPE_2:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_2_12,parent,false));
                itemView.initView02();
                break;
            case TYPE_3:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_3_12,parent,false));
                itemView.initView03();
                break;
            case TYPE_4:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_4_12,parent,false));
                itemView.initView04();
                break;
            case TYPE_5:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_5_12,parent,false));
                itemView.initView05();
                break;
            case TYPE_6:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_6_12,parent,false));
                itemView.initView06();
                break;
            case TYPE_7:
                itemView = new myItemView(mLayoutInflater.inflate(R.layout.item_7_12,parent,false));
                itemView.initView07();
                break;
        }
        return itemView;
    }


    @Override
    protected void initonBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof myItemView){
            myItemView holder1 = (myItemView) holder;
            int itemViewType = getItemViewType(position);
            switch (itemViewType){
                case TYPE_0:
                    holder1.initData00();
                    break;
                case TYPE_1:
                    holder1.initData01();
                    break;
                case TYPE_2:
                    holder1.initData02();
                    break;
                case TYPE_3:
                    holder1.initData03();
                break;
                case TYPE_4:
                    holder1.initData04();
                break;
                case TYPE_5:
                    holder1.initData05();
                break;
                case TYPE_6:
                    holder1.initData06();
                break;
                case TYPE_7:
                    holder1.initData07();
                break;
            }

        }
    }

    @Override
    public int getItemViewType(int position) {
        if (position ==0){
            return TYPE_0;
        }else if (position ==1){
            return TYPE_1;
        }else if (position ==2){
            return TYPE_2;
        }else if (position ==3){
            return TYPE_3;
        }else if (position ==4){
            return TYPE_4;
        }else if (position ==5){
            return TYPE_5;
        }else if (position ==6) {
            return TYPE_6;
        }else if (position ==7) {
            return TYPE_7;
        }


        return super.getItemViewType(position);
    }
    public class myItemView extends baseRecyclerview.itemView{

        private TextView mItem_0_12_tv;
        private TextView mItem_1_12_tv;
        private TextView mItem_2_12_tv;
        private ImageView item_0_12_iv;
        private ImageView item_3_12_iv;
        private ImageView item_2_12_iv;
        private ImageView item_4_12_iv;
        private ImageView item_5_12_iv;
        private ImageView item_6_12_iv;
        private ImageView item_7_12_iv;
        private ImageView mItem_1_12_iv;

        public myItemView(View itemView) {
            super(itemView);
        }
        public void initView00(){
            mItem_0_12_tv = (TextView) itemView.findViewById(R.id.item_0_12_tv);
            item_0_12_iv = (ImageView) itemView.findViewById(R.id.item_0_12_iv);

        }
        public void initData00(){
            mItem_0_12_tv.setText(json.titile0);
            Glide
                    .with(context)
                    .load(json.url0)
                    .into(item_0_12_iv);
        }
        public void initView01(){
            mItem_1_12_tv = (TextView) itemView.findViewById(R.id.item_1_12_tv);
            mItem_1_12_iv = (ImageView) itemView.findViewById(R.id.item_1_12_iv);

        }
        public void initData01(){
            mItem_1_12_tv.setText(json.titile1);
            Glide
                    .with(context)
                    .load(json.url1)
                    .into(mItem_1_12_iv);

        }
        public void initView02(){
            mItem_2_12_tv = (TextView) itemView.findViewById(R.id.item_2_12_tv);
            item_2_12_iv = (ImageView) itemView.findViewById(R.id.item_2_12_iv);
        }
        public void initData02(){
            mItem_2_12_tv.setText(json.titile2);
            Glide
                    .with(context)
                    .load(json.url2)
                    .into(item_2_12_iv);
        }
        public void initView03(){
            item_3_12_iv = (ImageView) itemView.findViewById(R.id.item_3_12_iv);
        }
        public void initData03(){
            Glide
                    .with(context)
                    .load(json.url3)
                    .into(item_3_12_iv);
        }
        public void initView04(){
            item_4_12_iv = (ImageView) itemView.findViewById(R.id.item_4_12_iv);
        }
        public void initData04(){
            Glide
                    .with(context)
                    .load(json.url4)
                    .into(item_4_12_iv);
        }
        public void initView05(){
            item_5_12_iv = (ImageView) itemView.findViewById(R.id.item_5_12_iv);
        }
        public void initData05(){
            Glide
                    .with(context)
                    .load(json.url5)
                    .into(item_5_12_iv);
        }
        public void initView06(){
            item_6_12_iv = (ImageView) itemView.findViewById(R.id.item_6_12_iv);
        }
        public void initData06(){
            Glide
                    .with(context)
                    .load(json.url6)
                    .into(item_6_12_iv);
        }
        public void initView07(){
            item_7_12_iv = (ImageView) itemView.findViewById(R.id.item_7_12_iv);

        }
        public void initData07(){
            Glide
                    .with(context)
                    .load(json.url7)
                    .into(item_7_12_iv);
        }
        public void initView08(){

        }
        public void initData08(){

        }
        public void initView09(){

        }
        public void initData09(){

        }
    }
}
